import React, { useState } from 'react'
import './index.less'
import { useQueryUnionId } from './use'
import Tool1Modal from './components/tool1-modal'
import PageList from './components/page-list'


function Page() {
  const [modelVisible, setModelVisible] = useState(false)
  const { val, search, loading } = useQueryUnionId('')

  const pageListProps = {
    onListClick() {
      setModelVisible(true)
    }
  }
  const modalProps = {
    onSearch: search,
    unionId: val,
    loading: loading,
    title: '添加配置信息',
    width: 800,
    cancelText: '取消',
    okText: '确认',
    item: {},
    visible: modelVisible,
    handleCancel() {
      setModelVisible(false)
    },
    handleOk(item) {
      search({ openId: item.openid })
    }
  }

  return (
    <div className="tools">
      <PageList {...pageListProps} />
      {modelVisible && <Tool1Modal {...modalProps} />}
    </div>
  )
}

export default Page
